﻿using DotNet.Utilities.ConsoleHelper;
using PropertyChanged;
using System;
using System.Collections.ObjectModel;
using System.Windows;
using WPFPractice.Models;
using WPFTemplateLib.WpfHelpers;

namespace WPFPractice.Windows
{
    public partial class WinWPFUI : Window
    {
        public WinWPFUI()
        {
            InitializeComponent();
            DataContext = new WPFUIViewModel();
        }
    }

    [AddINotifyPropertyChangedInterface]
    public class WPFUIViewModel: BindableBase
    {
        public WPFUIViewModel()
        {
            SetCommandMethod();

            InitValue();

            Console.SetOut(new ConsoleWriter(s =>
            {
                ShowInfo(s);
            }));
        }

        #region 绑定

        /// <summary>
        /// 测试数据
        /// </summary>
        public ObservableCollection<User> Datas { get; set; }

        #endregion

        /// <summary>
        /// 数据初始化
        /// </summary>
        private void InitValue()
        {
            Datas = new ObservableCollection<User>()
            {
                new User(){UserId = "1111", UserName = "张三", Gender = "男", Age = 20, MobileNum = "13597362875", Address = "浙江省杭州市西湖区古墩路", Signature = "好好学习，天天向上"},
                new User(){UserId = "2222", UserName = "李四", Gender = "男", Age = 22, MobileNum = "13385937628", Address = "福建省南平市邵武市水北镇", Signature = "生命不息，奋斗不止"},
                new User(){UserId = "3333", UserName = "王妩", Gender = "女", Age = 24, MobileNum = "17129463982", Address = "美利坚共和国加利福尼亚洲", Signature = "天妒英才，命运多舛"},
                new User(){UserId = "4444", UserName = "赵溜", Gender = "男", Age = 28, MobileNum = "18868839476", Address = "火星基地一号华中区杭州堡", Signature = "人生一世，草木一秋"},
            };
        }

        /// <summary>
        /// 命令方法赋值(在构造函数中调用)
        /// </summary>
        private void SetCommandMethod()
        {

        }
    }
}
